import type { SystemRole } from '@/api/modules/auth/roles';
import { STATUS_ENUM } from '@/enum/system';
import type { Rule } from 'ant-design-vue/es/form';
import { roleSelectedKeys } from './data';

const formObj: SystemRole = {
  roleName: '',
  roleKey: '',
  roleSort: 0,
  dataScope: '',
  menuCheckStrictly: false,
  deptCheckStrictly: false,
  status: STATUS_ENUM.NORMAL,
  createTime: '',
  remark: '',
  params: undefined,
  flag: false,
  menuIds: [],
  admin: false,
  roleId: '',
};
export const form = ref<SystemRole>({
  ...formObj,
});

export const formRef = ref();

export const resetForm = () => {
  roleSelectedKeys.value = [];
  form.value = {
    ...formObj,
  };
};
export const formRules: Record<keyof SystemRole, Rule[]> = {
  roleName: [{ required: true }],
  roleKey: [],
  roleSort: [],
  dataScope: [],
  menuCheckStrictly: [],
  deptCheckStrictly: [],
  status: [],
  createBy: [],
  createTime: [],
  updateBy: [],
  updateTime: [],
  remark: [],
  params: [],
  flag: [],
  menuIds: [],
  deptIds: [],
  admin: [],
  roleId: [],
};
